﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using VOL.Entity.DomainModels;
using VOL.Core.Filters;
using System;
using Microsoft.Extensions.Logging;
using Quartz.Logging;
using VoL.Domain.IServices;
using VoL.Domain.IServices.BasicData;
using VOL.WebApi.Common;
using VOL.WebApi.Common.DTO;

namespace VOL.WebApi.Controllers.BasicData.WardAreaHouse
{
    /// <summary>
    /// 病区病房API控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        /// <summary>
        /// 科室服务
        /// </summary>
        private readonly IOfficeService _officeService;
        /// <summary>
        /// 病区病房服务
        /// </summary>
        private readonly IWardServices _wardServices;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="officeService">科室服务</param>
        /// <param name="wardServices">科室服务</param>
        public ManagementController(IOfficeService officeService, IWardServices wardServices)
        {
            this._officeService = officeService;
            this._wardServices = wardServices;
        }

        /// <summary>
        /// 获取科室树形结构
        /// </summary>
        /// <returns>返回任务</returns>
        [HttpGet]
        public APIResult<List<OfficeDTO>> OfficeHouseTree()
        {
            return _officeService.OfficeHouseTree();
        }

        /// <summary>
        /// 获取病房
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返填</returns>
        [HttpGet]//http://localhost:9991/api/Management/WardAreaWardHouse
        public APIResult<List<WardAreaWardDTO>> WardAreaWardHouse(int wardAreaId)
        {
            return _wardServices.WardAreaWardHouse(wardAreaId);
        }

        /// <summary>
        /// 添加病区病房配置
        /// </summary>
        /// <returns>返回数据</returns>
        [HttpPost]
        public async Task<APIResult<object>> SaveWardServices(int wardAreaId, string wardIds)
        {
            // 调用服务层方法保存病区病房配置
            var result = await _wardServices.SaveWardServices(wardAreaId, wardIds);
            // 返回结果
            return result;
        }


        //Logger.Info();
        //Logger.Error();
        // VOL.Core.Services.Logger.Info()/Error()
        // //企业版
        // VolPro.Core.Services.Logger.Info()/Error()

        //[ApiTask]
        //[HttpGet, HttpGet]
        //public IActionResult test()
        //{
        //    return Content(DateTime.Now.ToString("yyyyy-MMMM-dddd HH:mm:sss:fff"));
        //}

        ///// <summary>
        ///// 获取科室树形结构
        ///// </summary>
        ///// <param name="request">请求</param>
        ///// <returns>返回任务</returns>
        //[HttpGet]
        //public Task<APIResult<List<OfficeDTO>>> OfficeTree(OfficeTreeCommand request)
        //{
        //    return mediator.Send(request);
        //}

        ///// <summary>
        ///// 保存病区病房分配
        ///// </summary>
        ///// <param name="request">请求</param>
        ///// <returns>返回任务/returns>
        //[HttpPost]
        //public async Task<APIResult<object>> SaveWardAllocation(SaveWardAllocationCommand request)
        //{
        //    return await mediator.Send(request);
        //}
    }
}
